
var app = angular.module('app', ['ngRoute', 
								 'ngCookies',
								 'ngAnimate',
								 'ngSanitize',
								 'ui.bootstrap',
								 'angularFileUpload',

								 'appControllers',
								 'appDirectives',
								 'appServices',
								 'appFilters']);

//var g_data = ['$q', function($q){ // $q 是angular内置服务
//                        var defer = $q.defer(); //声明延后执行
//                        setTimeout(function(){
//                            defer.resolve(''); //promise resolve完成承诺
//							//else defer.reject(data); // 承诺完成失败
//                        }, 1000);
//                        return defer.promise; //返回承诺
//                    }];

app.config(['$routeProvider', '$locationProvider',
	function ($routeProvider, $locationProvider) {

		$locationProvider.html5Mode(true);

		$routeProvider.
		when('/', {
			templateUrl: 'posts.html',
			//controller: postsCtrl
			controller: 'postsCtrl' //使用注册的controller需要加引号
		}).
		when('/welcome', {
			templateUrl: 'welcome.html'
		}).
		when('/hot', {
			templateUrl: 'posts.html',
			controller: 'postsCtrl'
		}).
		when('/tag/:tag', {
			templateUrl: 'posts.html',
			controller: 'postsCtrl'
		}).
		when('/login', {
			templateUrl: 'login.html',
			controller: 'loginCtrl'
		}).
		when('/regist', {
			templateUrl: 'regist.html',
			controller: 'registCtrl'
		}).
		when('/say', {
			templateUrl: 'say.html',
			controller: 'sayCtrl'
		}).
		when('/sayDone', {
			templateUrl: 'sayDone.html'
		}).
		when('/:user',{
			templateUrl: 'home.html',
			controller: 'homeCtrl'
		}).
		when('/:user/settings', {
			templateUrl: 'settings.html',
			controller: 'settingsCtrl'
		}).
        when('/post/:postId', {
            templateUrl: 'specific.html',
            controller: 'specificCtrl'
        }).
		otherwise({
			redirectTo: '/' // 其他情况，跳到链接"/"
		});
}]);
